﻿using S7Project_One.Table;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace S7Project_One.Base
{
    public class FreeBase
    {
        public static IFreeSql SQL;
        static public void InitFreeSql()
        {
            try
            {
                string connectSQLStr = @"Data Source=127.0.0.1;Port=3306;User ID=root;Password=Qwertyuiop0928..; Initial Catalog=testdb;Charset=utf8mb4; SslMode=none;Min pool size=1
";
                //创建一个FreeSql实例
                SQL = new FreeSql.FreeSqlBuilder()
                    .UseConnectionString(FreeSql.DataType.MySql, connectSQLStr)
                    .UseMonitorCommand(cmd => Console.WriteLine($"---SQL----：{cmd.CommandText}"))
                    .Build();
                SQL.GlobalFilter.Apply<UserTable>("search", a => a.DeletedTime == null);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }
        }

    }
}
